
/*CheckInfo  检测结果*/
import request from "/@/utils/request";
import download from "/@/utils/download.ts";

const CheckInfoApi = {

    getPageData(data: any) {
        return request({
            url: "/checkInfo/pageData",
            method: "post",
            data,
        });
    },
    getDetail(data: any) {
        return request({
            url: "/checkInfo/getDetail",
            method: "post",
            data,
        });
    },

    save: (data: any) => {
        return request({
            url: "/checkInfo/save",
            method: "post",
            data,
        });
    },
  downloadAttachment:(url: any, name?: any) => {
      console.log("url",url)
      const item = url.split("/")
      const fileName = name ? name : item[item.length - 1]
      console.log("fileName：",fileName)
      axios({
          method: "get",
          url,
          responseType:"blob"
      }
      ).then(res=>{
          download(res,fileName)
      })
  },
    del: (data: any) => {
        return request({
            url: "/checkInfo/del",
            method: "post",
            data,
        });
    },

    updateStatus: (data: any) => {
        return request({
            url: "/checkInfo/updateStatus",
            method: "post",
            data,
        });
    },
    pageDataXls:(_searchParam: any,_xlsTitle: any) => {
           const param = new URLSearchParams();
        param.append("_searchParam",JSON.stringify(_searchParam))
        param.append("_xlsTitle",_xlsTitle)
        return request({
            url: "/checkInfo/pageDataXls",
            method: "post",
            responseType: 'blob',
            headersType: 'application/json;charset=UTF-8',
                     params:param,

        }).then((res)=> {
            download(res)
        });
    },
};
export default CheckInfoApi;
